/**
//  * @description 全局公共状态
//  */

 import { setCookie } from "@/utils/jsCookie";
 import { getAllWarehouseSpinner } from "@/api/app";
//  import store from "@/store";
 
 export default {
     state: ()=> ({
         isCollapse: false,  // 左侧菜单展开状态记录
         hasError: false,    // 是否有异常
         pageSizes: [10, 15, 25, 50, 100, 150],
         warehouseList: null   // 仓库列表（全局共用）
     }),
     getters: {
         menuIsCollapse: (state) => state.isCollapse,
         hasError: (state) => state.hasError,
         warehouseList: (state) => {
             if(state.warehouseList instanceof Array) {
                 return state.warehouseList;
             } else {
                //  store.dispatch('app/getAllWarehouse');
             }
         }
     },
     mutations: {
         increment (state) {
             state.count++
         },
         switchCollapse(state, isCollapse){
             setCookie('isCollapse', isCollapse);
             state.isCollapse = isCollapse;
         },
         hasError (state, flag) {
             state.hasError = flag
         },
         setWarehouseList(state, list) {
             state.warehouseList = list;
         },
     },
     actions: {
         switchMenuCollapse({commit}, isCollapse){
             commit('switchCollapse', isCollapse)
         },
         hasError({commit}, flag){
             commit('hasError', flag)
         },
         getAllWarehouse({commit}){
             return new Promise((resolve)=> {
                 getAllWarehouseSpinner().then(res=> {
                     commit('setWarehouseList', res)
                     resolve(res);
                 })
             })
         },
     }
 }